<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>WebSSH</title>
  <style>
    #terminal {
      width: 100%;
      height: 100vh;
    }
  </style>
</head>
<body>
  <div id="terminal">

  </div>
  <script src="https://cdn.socket.io/4.0.1/socket.io.min.js"></script>
  <script src="https://unpkg.com/xterm@4.14.0/dist/xterm.js"></script>
  <script>
    const socket = io();

    const term = new Terminal();
    term.open(document.getElementById('terminal'));

    term.onData((data) => {
      socket.emit('input', data);
    });

    socket.on('output', (data) => {
      term.write(data);
    });
  </script>
</body>
</html>
